var StickerMsgSender = (function(){
    
    var _StickerMsgSender = (function(){}).extend(MsgSender);
    
    _StickerMsgSender.prototype.send = function(cb){
        var _this = this;
        
        var chatGroupEntity = page.chatGroupStore.getItem(_this.chatGroupID);
        var stickerData = {
            contentType : 'sticker',                    
            content : JSON.stringify(_this.content),
            seq : 0,
            createTime : Date.now()
        };            
        if(chatGroupEntity.perm.rloc && page.position){
            stickerData['la'] = page.position.coords.latitude;
            stickerData['lo'] = page.position.coords.longitude;
        }            
        //呈现StickerMsg.
        var stickerMsg = (new ChatStickerMsg(stickerData, 'right')).render(_this.chatPanel.chatView);
        
        stickerMsg.markSending();
        
        var flag = false;
        if(stickerMsg.canShowReaders()){
            flag = true;
            stickerMsg.disableShowReaders();
        }
        
        $.post('/apis/chat/topic', {
            teid : this.chatGroupID,
            type : 'sticker',
            content : this.content        
        }).then(ujs.hr(function(msg){
            stickerMsg.clearSending();             if(_this.chatPanel.chatGroupEntity.type == 'singlechat'){                stickerMsg.setUnread();            }
            //将StickerMsg添加到本地缓存.
            page.chatMsgStore.addItem({
                local : true,
                teid : _this.chatGroupID,
                seq : msg['seq'],
                createTime : msg['time'],
                contentType : MsgType.STICKER,
                from : 'web',
                id : msg['id'],
                content : _this.content,
                user : _this.user
            });       
            stickerMsg.updateSeq(msg['seq']).updateMsgTime(msg['time']);
            stickerMsg.adjustPos(msg['seq']).chatView.refreshReadCount();
            if(flag){
                stickerMsg.enableShowReaders();
            }         
            cb && cb(msg);       
        }, function(){            stickerMsg.markFailed();            stickerMsg.$retryBtn.click(function(){                stickerMsg.hide();                _this.send(function(){                    _this.chatPanel.chatView.$wrapper.scrollToEnd();                });                return false;            });        })).fail(function(){
            stickerMsg.markFailed();
            stickerMsg.$retryBtn.click(function(){
                stickerMsg.hide();
                _this.send(function(){
                    _this.chatPanel.chatView.$wrapper.scrollToEnd();
                });
                return false;
            });
        });
    };
    
    return _StickerMsgSender;
})();